﻿#include "saveimgworker.h"
#include <QDir>
#include <QDebug>
SaveImgWorker::SaveImgWorker(QObject *parent) : QObject(parent)
{

}



SaveImgWorker::~SaveImgWorker()
{

}
void SaveImgWorker::Initialize()
{

}

void SaveImgWorker::start(CameraData m_cImageInfo)
{
	QString strPath = QDir::currentPath() + "/Pic";
	switch (m_cImageInfo.m_nIndex) {
	case 1:
		strPath += "/ccd1";
		break;
	case 2:
		strPath += "/ccd2";
		break;
	case 3:
		strPath += "/ccd3";
		break;
	case 4:
		strPath += "/ccd4";
		break;
	}

	switch (m_cImageInfo.m_nNGorOK) {
	case 0:
        if (m_nSaveType == 0 || m_nSaveType == 1 || m_nSaveType == 2){
			return;
		}
		strPath += "/OK/";
		break;
	case 1:
		if (m_nSaveType == 1){
			return;
		}
		strPath += "/NG/";
		break;
	default:
		if (m_nSaveType == 0){
			return;
		}
		strPath += "/Abnormal/";
		break;
	}
	QString path = QString("%1%2.bmp").arg(strPath).arg(m_nIndex);
	HalconCpp::WriteImage(m_cImageInfo.Hobj, "bmp", 0, path.toStdString().c_str());
	m_nIndex++;
}

